1. Field of the Invention
The present invention relates to a displacement estimation device and a method for the same; in particular, the present invention relates to a device and a method for estimating the displacement between two patterns in two successive images.
2. Description of the Related Art
Referring to FIG. 1, a conventional optical mouse typically comprises an image capture device 221 and a displacement calculator 222.
The image capture device 221 continuously captures images and transmits the images to the displacement calculator 222. The displacement calculator 222 compares patterns in two successive images and calculates a displacement vector corresponding to the displacement between two corresponding patterns. The displacement vector, as a result of the calculation, is sent to a computer (not shown) by the displacement calculator 222, for moving a cursor on a computer screen.
Referring to FIG. 2, as an example, the image capture device 221 captures a first image IMAGE1 at a first timing, and later captures a second image IMAGE2 at a second timing, wherein both the first and the second images have a size of 7×7 pixels.
According to prior art, the method for calculating a displacement vector from the first image to the second image includes the following steps: first, selecting a region of interest (ROI) in the first image; next, determining which location has the ROI moved to in the second image; and last, calculating a displacement vector based on the location information.
Referring to FIG. 3, a conventional method is shown in which the displacement vector is calculated by correlation estimation. The method moves the ROI around the second image and estimates the correlations between the ROI and image regions in different locations on the second image. The location of an image region most correlated to the ROI is the most matching location, i.e., the pattern in this location is most similar to the pattern in the ROI. Then, the location of the ROI in the first image and the most correlated location in the second image may be used to obtain the displacement vector.
In the abovementioned conventional method, the correlation is basically estimated by superimposing two images and calculating the intensity difference between two superimposed pixels. However, if the pattern in any of the two images is distorted, such as rotated, shrunk, or enlarged, or if the pattern is shaded from light, it may easily induce errors in the displacement estimation, for that the method only considers the intensities of the pixels, without taking into consideration the relative relationships among the pixels.
U.S. Pat. No. 6,859,199 B2 discloses another method for use by the displacement calculator 222. The method first calculates the difference between the intensities of two adjacent pixels. The difference is accepted as a feature and included in a feature set only if the absolute value of the difference is larger than a threshold. A feature set is obtained after completing calculation for all the differences between adjacent pixels. The displacement vector from the feature set of the first image to the feature set of the second image is determined to be the displacement vector from the pattern of the first image to the pattern of the second image.
As a more specific example, referring to FIG. 4, each pixel in the first image has an intensity value as shown in the figure. According to the '199 patent, a difference table is obtained by subtracting the intensity value of each pixel from the intensity value of its right-side adjacent pixel, as shown in FIG. 5. Assuming a threshold is set at 20, then a feature set is formed by all the differences larger than 20, as shown by the circled numbers in FIG. 5.
By the same manner, the second image is processed to obtain a difference table as shown in FIG. 6; likewise, the circled numbers in FIG. 6 form the feature set of the second image.
Next, a displacement vector is calculated by comparing the feature set of the first image and the feature set of the second image. By comparing the feature sets in FIGS. 5 and 6, it can be seen that the feature set of the second image has moved one pixel rightward from the location of the feature set of the first image, and thus the displacement vector is (1, 0). This is the displacement vector from the pattern of the first image to the pattern of the second image.
The abovementioned method has a drawback in that, because the intensity difference between pixels in an image may be influenced by noises, the choice of the threshold is very critical to the generation of the feature set. However, it is difficult to choose an optimum threshold, and any inferior choice will negatively impact the estimation of the displacement vector.